﻿/*----------------------------------------------------------------
//  <copyright file="UserTokenBase.cs" company="MicroCloud@151504200868">
//      Copyright © 2020-2024 MicroCloud Corporation, All rights reserved.
//  </copyright>
//  <site>https://gitee.com/chenmm123/microclouds</site>
//  <last-editor>cmm</last-editor>
//  <last-date>2023-12-07 08:17</last-date>
//----------------------------------------------------------------*/

namespace MicroCloud.Identity.Entities
{
    #region "表示用户的身份验证令牌的基类"
    /// <summary>
    /// 表示用户的身份验证令牌的基类
    /// </summary>
    /// <typeparam name="TKey">用户令牌编号类型</typeparam>
    /// <typeparam name="TUserKey">用户编号类型</typeparam>
    [EventEntityIgnore]
    public abstract class UserTokenBase<TKey, TUserKey> : EntityBase<TKey>, ICreatedTime
        where TKey : struct, IEquatable<TKey>
        where TUserKey : struct, IEquatable<TUserKey>
    {
        #region "属性"
        #region "获取或设置 用户编号"
        /// <summary>
        /// 获取或设置 用户编号
        /// </summary>
        [Column("UserId")]
        [Required]
        [DisplayName("用户编号")]
        public TUserKey UserId { get; set; }
        #endregion

        #region "获取或设置 当前用户标识的登录提供者"
        private string _LoginProvider = "";
        /// <summary>
        /// 获取或设置 当前用户标识的登录提供者
        /// </summary>
        [Column("LoginProvider")]
        [Required, DefaultValue("")]
        [StringSize(StringSizeType.Name)]
        [DisplayName("登录提供者")]
        public string LoginProvider { get { return _LoginProvider; } set { _LoginProvider = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 令牌名称"
        private string _Name = "";
        /// <summary>
        /// 获取或设置 令牌名称
        /// </summary>
        [Column("Name")]
        [Required, DefaultValue("")]
        [StringSize(StringSizeType.Name)]
        [DisplayName("令牌名称")]
        public string Name { get { return _Name; } set { _Name = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 令牌值"
        private string _Value = "";
        /// <summary>
        /// 获取或设置 令牌值
        /// </summary>
        [Column("Value")]
        [Required, DefaultValue("")]
        [StringMax]
        [DisplayName("令牌值")]
        public string Value { get { return _Value; } set { _Value = value.ReplaceNull(); } }
        #endregion

        #region "获取或设置 创建时间 ICreatedTime、ICreationAudited  可装载接口，在数据创建时可自动设置当前时间"
        /// <summary>
        /// 获取或设置 创建时间
        /// </summary>
        [Column("CreatedTime")]
        [DisplayName("创建时间")]
        public DateTime CreatedTime { get; set; }
        #endregion

        #endregion

    }
    #endregion

}
